package ${package.Controller};

import com.syscom.admin.service.${entity}Service;
import com.syscom.common.base.BasePage;
import com.syscom.common.entity.${entity};
import com.syscom.common.utils.result.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;

<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
* @author ${author}
* @Date ${date}
*/
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/${lowerEntityName}")
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>

    @Autowired
    private ${entity}Service ${lowerEntityName}Service;

    @ApiOperation("${entity}查询接口")
    @GetMapping("/query${entity}")
    public AjaxResult query${entity}(BasePage basePage<#if queryObj??><#list queryObj?keys as key>, String ${key}</#list></#if>) {

        return ${lowerEntityName}Service.query${entity}(basePage<#if queryObj??><#list queryObj?keys as key>, ${key}</#list></#if>);
    }

    @ApiOperation("${entity}新增接口")
    @PostMapping("/add${entity}")
    public AjaxResult add${entity}(@RequestBody ${entity} ${lowerEntityName}) {

        return ${lowerEntityName}Service.add${entity}(${lowerEntityName});
    }

    @ApiOperation("${entity}更新接口")
    @PatchMapping("/update${entity}/{objectId}")
    public AjaxResult update${entity}(@PathVariable Long objectId, @RequestBody ${entity} ${lowerEntityName}) {

        ${lowerEntityName}.setObjectId(objectId);
        return ${lowerEntityName}Service.update${entity}(${lowerEntityName});
    }

    @ApiOperation("${entity}删除接口")
    @DeleteMapping("/delete${entity}/{objectId}")
    public AjaxResult delete${entity}(@PathVariable Long objectId) {

        return ${lowerEntityName}Service.delete${entity}(objectId);
    }

}

